﻿using UnityEngine;
using System.Collections;

public class MemoryCards : MonoBehaviour {
	public int cardnumber;
	public Texture background;
	[SerializeField] Texture mat;
	[SerializeField] bool SelectCard = false;
	private logic_cards choncard=null;


	// Use this for initialization
	void Start () {
		choncard = Camera.main.GetComponent<logic_cards>();
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void SetNumberCards(Texture t , int number)
	{
		renderer.materials [0].mainTexture = t;
		cardnumber = number;

		mat = t;
	}


	public void showCard()
	{
		if (!SelectCard) {
						SelectCard = true;
						
						renderer.materials [1].mainTexture = mat;
						choncard.selectCardsLogic(this);
				}
	}
	public void deleteCard()
	{
		Debug.Log ("Destroy");
		Destroy (gameObject);
	}
	public void SelectNotrue()
	{
		SelectCard = false;
		StartCoroutine ("ResetMaterial");
	}
	IEnumerator ResetMaterial()
	{
		Debug.Log ("--------------------");
		yield return new WaitForSeconds (.5f);
		renderer.materials[1].mainTexture =background;
	}

}
